<template>
	<view class="container">
		<view class="content">
			<!-- //编辑区域 -->
			<view class="top_container">
				<view class="center_button">
					<view class="center_button_add">
						+
					</view>
					<text>编辑内容</text>
				</view>
				<view class="text" v-if="text!=''">
					dsajdjhsajdhasj
				</view>
			</view>
		</view>
		<!-- 操作区域 -->
		<view class="bottonflexed">
			<scroll-view class="scroll-view_H" scroll-x="true">
				<view class="scroll-view-item" v-for="item in listData" :key="item.type" @click="showDrawer(item)">
					<view class="item">
						<image :src=" '../../static/c'+ item.type +'.png'" mode=""></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<uni-popup ref="showLeft" type="bottom" safeArea backgroundColor="#fff" @change="change">
			<view class="contenttext" :style="{height:popType.type == 1?'1000rpx':'auto'}">
				<view class="contentselect">
					<view class="left" v-if="popType.list.length>1">
						<view :class="ind == index?'item active':'item'" v-for="(item,index) in popType.list"
							:key="index" @click.stop="clickchange(index)">
							{{item}}
						</view>
					</view>
					<view class="center" v-else>
						{{popType.list[0]}}
					</view>
					<view class="right" @click.stop="closeDrawer('showLeft')">
						x
					</view>
				</view>
				<swiper class="swiper" @change="swiperchange" :current='ind'>
					<swiper-item v-if="popType.type == 1">
						<view class="swiper-item uni-bg-red" style="background: red;">A</view>
					</swiper-item>
					<swiper-item v-if="popType.type == 1">
						<view class="swiper-item uni-bg-green">B</view>
					</swiper-item>
				</swiper>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: '',

				popType: {
					type: 0,
					list: [],
				}, //弹出配置
				ind: 0, //记录切换
				listData: [{
						imgUrl: '',
						name: '背景',
						type: 1,
						list: ['背景色', '纯色']
					},
					{
						imgUrl: '',
						name: '编辑内容',
						type: 2,
					},
					{
						imgUrl: '',
						name: '首图样式',
						type: 3,
						list: ['首图字体', '字体颜色', '字行间距', '布局设置']
					},
					{
						imgUrl: '',
						name: '正文样式',
						type: 4,
						list: ['正文字体', '正文颜色', '字行间距', '布局设置']
					},
					{
						imgUrl: '',
						name: '局部样式',
						type: 5,
					},
					{
						imgUrl: '',
						name: '添加水印',
						type: 6,
						list: ['水印设置']
					},
					{
						imgUrl: '',
						name: '页眉显示',
						type: 7,
						list: ['页眉显示']
					}
				] //配置项
			}
		},

		methods: {
			//打开
			showDrawer(item) {
				this.popType = item
				this.$refs['showLeft'].open()
			},
			//关闭
			closeDrawer(e) {
				this.$refs[e].close()
			},
			change(e) {
				console.log(e);
				if (e.show == false) {
					this.ind = 0
				}
			},
			//切换
			clickchange(index) {
				this.ind = index
			},
			swiperchange(e){
				this.ind = e.detail.current
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 0 30rpx;

		.top_container {
			width: 100%;
			height: 800rpx;
			background: white;
			position: relative;
		}

		.center_button {
			text-align: center;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

			.center_button_add {
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				border: 2px solid black;
				line-height: 80rpx;
				font-size: 40rpx;
				font-weight: 800;
				margin-bottom: 20rpx;
			}

			text {
				font-size: 30rpx;
			}
		}
	}

	//操作区域
	.bottonflexed {
		width: 100%;
		background: white;
		position: fixed;
		bottom: 0;
		height: 150rpx;

		.scroll-view_H {
			white-space: nowrap;
			width: 100%;
			height: 100%;
		}

		.scroll-view-item {
			text-align: center;
			display: inline-block;
			width: 18%;
			height: 100%;
			text-align: center;

			.item {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				font-size: 28rpx;

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

		::-webkit-scrollbar {

			display: none;

		}
	}

	.active {
		color: red !important;
	}

	//弹出
	.contenttext {
		padding: 20rpx;
		position: relative;

		.contentselect {
			margin-bottom: 50rpx;
			.left {
				display: flex;
				align-items: center;

				.item {
					margin-right: 20rpx;
					font-size: 30rpx;
				}
			}

			.center {
				text-align: center;
			}

			.right {
				font-size: 65rpx;
				color: gray;
				font-weight: 500;
				position: absolute;
				right: 20rpx;
				top: -10rpx;
			}
		}
	}

	::v-deep .uni-popup__wrapper {
		border-radius: 30rpx 30rpx 0 0;
	}

	::v-deep .noback .vue-ref:last-child {
		background: transparent !important;
	}
</style>
